import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:thinking/config/_.dart';
import 'package:thinking/entity/_.dart';
import 'package:thinking/event/_.dart';




class TopicButton extends StatelessWidget  {

  final bool isSub;
  final Function callBack;
  final bool isUpdate;
  final Tag topic;
  TopicButton({required this.isSub,required this.callBack,this.isUpdate:true,required this.topic});



  @override
  Widget build(BuildContext context) {
    return Container(
      width: 80,
      child:  TextButton(
            style: ButtonStyle(
              textStyle: MaterialStateProperty.all(TextStyle(fontSize: 14)),
              backgroundColor:MaterialStateProperty.all(isSub?ColorConfig.ThemeColor:ColorConfig.WhiteBackColor),
              shape:MaterialStateProperty.all(
                  RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(8))
                  )
              ),
                side: isSub?null:MaterialStateProperty.all(
                    BorderSide(
                      width: 1.0,
                      color: ColorConfig.ThemeColor

                    )
                ),
              foregroundColor:
              MaterialStateProperty.all(isSub?ColorConfig.WhiteBackColor:ColorConfig.ThemeColor),

            ),
            child: Text(this.isSub?'已订阅':'+  订阅'),
            onPressed: () async{
             await callBack();
             Config.eventBus.fire(TopicClassEvent(isUpdate,topic.tagClassIndex!,topic.tagStatus == 3));

            },
      ),
    );
  }

}